package com.yonyou.iuap.jxzy.service;

import java.util.HashMap;
import java.util.Map;

import nc.vo.pub.lang.UFDateTime;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonObject;
import com.yonyou.iuap.jxzy.dao.ReceiveUnattendedMapper;
import com.yonyou.iuap.jxzy.utils.HttpRequestUtil;
import com.yonyou.uap.ieop.security.util.HttpUtil;

@Service
public class ReceiveUnattendedService {
	
	@Autowired
	private ReceiveUnattendedMapper receiveUnattendedMapper;
	
	public static final String SPQURL = "http://164.70.12.29:8080/unattended_hardware/hardwareOperation/openGate";
	/**
	 * 更具车牌号查询是否可以进场
	 * @return
	 */
	public String identifiedCarno(Map<String,String> map){
		String res = "false";
		String carno_identified = map.get("carno_identified");//车牌号
		map.put("ts", new UFDateTime().toString());
		this.receiveUnattendedMapper.insertbcclsb(map);
		if(carno_identified!=null && carno_identified.length()>0){
			carno_identified=carno_identified.toUpperCase();//变大写
			String deviceCode = map.get("deviceCode");//设备编码
			String pk_delivery = this.receiveUnattendedMapper.queryReceiptBillByVehicle(carno_identified);
			if(pk_delivery == null || pk_delivery.length() == 0){//说明改车辆未预约不能进厂
				System.out.println("车辆未预约不能进厂");
			}else{//进行升起道闸操作
				String deviceCode_dz = this.receiveUnattendedMapper.queryRoadGateByCode(deviceCode);
				JSONObject json = new JSONObject();
				json.put("deviceCode", deviceCode_dz);
				res = HttpRequestUtil.sendPost(SPQURL, json.toJSONString());
			}
		}
		return res;
	}
	
}
